package com.ruoyi.tongban.service.impl;

import java.util.List;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.common.utils.SecurityUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.tongban.mapper.TInstitutionMapper;
import com.ruoyi.tongban.domain.TInstitution;
import com.ruoyi.tongban.service.ITInstitutionService;

/**
 * 机构Service业务层处理
 * 
 * @author caiyanshan
 * @date 2021-03-09
 */
@Service
public class TInstitutionServiceImpl implements ITInstitutionService 
{
    @Autowired
    private TInstitutionMapper tInstitutionMapper;

    /**
     * 查询机构
     * 
     * @param institutionId 机构ID
     * @return 机构
     */
    @Override
    public TInstitution selectTInstitutionById(Long institutionId)
    {
        return tInstitutionMapper.selectTInstitutionById(institutionId);
    }

    /**
     * 查询机构列表
     * 
     * @param tInstitution 机构
     * @return 机构
     */
    @Override
    public List<TInstitution> selectTInstitutionList(TInstitution tInstitution)
    {
        return tInstitutionMapper.selectTInstitutionList(tInstitution);
    }

    /**
     * 新增机构
     * 
     * @param tInstitution 机构
     * @return 结果
     */
    @Override
    public int insertTInstitution(TInstitution tInstitution)
    {
        tInstitution.setStatus(1);
        tInstitution.setCreateUser(SecurityUtils.getLoginUser().getUser().getUserId());
        tInstitution.setCreateTime(DateUtils.getNowDate());
        return tInstitutionMapper.insertTInstitution(tInstitution);
    }

    /**
     * 修改机构
     * 
     * @param tInstitution 机构
     * @return 结果
     */
    @Override
    public int updateTInstitution(TInstitution tInstitution)
    {
        tInstitution.setUpdateTime(DateUtils.getNowDate());
        return tInstitutionMapper.updateTInstitution(tInstitution);
    }

    /**
     * 批量删除机构
     * 
     * @param institutionIds 需要删除的机构ID
     * @return 结果
     */
    @Override
    public int deleteTInstitutionByIds(Long[] institutionIds)
    {
        return tInstitutionMapper.deleteTInstitutionByIds(institutionIds);
    }

    /**
     * 删除机构信息
     * 
     * @param institutionId 机构ID
     * @return 结果
     */
    @Override
    public int deleteTInstitutionById(Long institutionId)
    {
        return tInstitutionMapper.deleteTInstitutionById(institutionId);
    }
}
